1221B - Knights - CodeForces Solution


constructive algorithms greedy *1100

Please click on ads to support us..

Python Code:

n = int(input())
a = 1
for c in range (0,n):
    for v in range (0,n):
        if a == 1:
            print("W" if v % 2 == 0 else "B", end="")
        else:
            print("B" if v % 2 == 0 else "W",end="")
    a = 1 if a == 0 else 0
    print()

C++ Code:

    #include <bits/stdc++.h>
    using namespace std;

    #define oset                 tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define M                    1e10+9
    #define pi                     3.14159265358979323846
    #define cel(x,a)            (((x) + (a) - 1) / (a))
    #define int                   long long
    #define pii                     pair<int,int>
    #define pb                     push_back
    #define lb                      lower_bound
    #define ub                     upper_bound
    #define ps(x,y)              fixed<<setprecision(y)<<x
    #define pf(x,y)              setfill('x')<<setw(y)
    #define mem(a,b)             memset(a,b,sizeof(a))
    #define F                        first
    #define S                        second
    #define countofbits(n)   __builtin_popcount(n)
    #define lcm(m, n)         (((m) / __gcd((m), (n)))*(n))
    #define all(v)                  v.begin(), v.end()
    #define sz(s)                   (int)(s.size())
    #define getline(s)           getline(cin >> ws, s)
    #define YES                   cout<<"YES"<<endl
    #define NO                    cout<<"NO"<<endl
    #define cz                     cout<<0<<endl
    #define Kremes              int t; cin>>t; while(t--)
    #define q                         queue<int>
    #define vi                       vector<int>
    #define vp                      vector<pair<int,int>>
    #define vs                      vector<string>
    #define fre(i,a,b)            for(int (i)=(a);(i)<(b);i++)
    #define fri(i,a,b)             for(int (i)=(a);(i)<=(b);i++)
    #define inp(a,n)             for(int i=0; i<n; i++) cin>>a[i];
    #define ct(a)                   cout<<a<<"\n"
    #define cts(a)                   cout<<(a)<<" "
    #define cn                 cout<<-1<<endl
    #define ndl                cout<<"\n"
    #define nl                 cout<<endl
    #define vi                  vector<int>
    #define mp                  map<int,int>
    #define lst                   (cl.size()-1)
    #define tell_time            cerr << "Time Taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << "\n";
    #define r(s)                     reverse((s).begin(),(s).end())

    void cline()          { cout << '\n';}
    template <typename T, typename... V>
    void cline(T t, V... v) {cout << t; if (sizeof...(v))cout << ' '; cline(v...);}
    void cspc()          { cout << ' ';}
    template <typename T, typename... V>
    void cspc(T t, V... v) {cout << t; if (sizeof...(v))cout << ' '; cspc(v...);}

    const int N = 1000007;

    void Poffertjes(){
     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
        // freopen("##.in", "r", stdin);
        //#ifndef ONLINE_JUDGE
         //freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
       // #endif
    }

    int min (int x, int y) {
        return (x < y) ? x : y;
    }

     //your code goes from here............................................................
    void makememove(){
        int n; cin>>n;
        fre(i,0,n){
          fre(j,0,n){
           cout<< (((i+j)%2==0)?"W":"B");
          }
          nl;
        }
      }

    int32_t main(){
            Poffertjes();
         //Kremes
         {
              makememove();
              tell_time;
        }
          return 0;

    }
   


Comments

Submit
0 Comments
More Questions

49A - Sleuth
1541A - Pretty Permutations
1632C - Strange Test
673A - Bear and Game
276A - Lunch Rush
1205A - Almost Equal
1020B - Badge
1353A - Most Unstable Array
770A - New Password
1646B - Quality vs Quantity
80A - Panoramix's Prediction
1354B - Ternary String
122B - Lucky Substring
266B - Queue at the School
1490A - Dense Array
1650B - DIV + MOD
1549B - Gregor and the Pawn Game
553A - Kyoya and Colored Balls
1364A - XXXXX
1499B - Binary Removals
1569C - Jury Meeting
108A - Palindromic Times
46A - Ball Game
114A - Cifera
776A - A Serial Killer
25B - Phone numbers
1633C - Kill the Monster
1611A - Make Even
1030B - Vasya and Cornfield
1631A - Min Max Swap